package com.atguigu.object;

public class Person {
    //属性私有化
    private String name;
    private int age;

    //无参构造
    public Person() {
    }

    //有参构造
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    //get/set
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //重写toString，
    // 快捷键（1）Alt + Insert，选toString （2）Ctrl + O
    /*
    以下代码是Ctrl + O生成的代码模板
    @Override
    public String toString() {
        return super.toString();
    }
     */
    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
